package com.novelastudios.application
{	
	import eu.orangeflash.managers.CMManager;
	
	import flash.display.Sprite;
	import flash.events.ContextMenuEvent;
	import flash.system.System;
	
	/**
	 * Among many things that this base class could be used for, what it currently does is 
	 * 	1. Changes the ContextMenu to show the application name and version 
	 * 
	 * @dependencies 
	 * 	External Libraries and Files
	 * 	 eu.orangeflash.managers.CMManager
	 * 
	 * @example Place this on the root of your application
	 * 	<listing version="3.0">
	 * 		import com.novelastudios.application.ApplicationStandardSetup;
	 * 		private const APP_NAME:String 	 = "My Application";
	 *		private const APP_VERSION:String = "1.0.0.0";
	 *		new ApplicationStandardSetup(this,APP_NAME,APP_VERSION);
	 * 	</listing> 
	 * @author johnbailey
	 * 
	 */	
	public class ApplicationStandardSetup
	{
		public function ApplicationStandardSetup(root:Sprite,appName:String,appVersion:String,copyright:String=null,manager:CMManager=null)
		{			
			ApplicationInformation.name 	= appName;
			ApplicationInformation.version 	= appVersion;
			
			_cmManager = manager ? manager : new CMManager(root);
			_cmManager.add(appName,function(event:ContextMenuEvent):void{ System.setClipboard(appName) },(_cmManager.customItems.length > 0));
			_cmManager.add("version "+appVersion,function(event:ContextMenuEvent):void{ System.setClipboard(appVersion) });
			if(ApplicationInformation.isBeta)_cmManager.add("BETA",function(event:ContextMenuEvent):void{ });
			if(ApplicationInformation.isAlpha)_cmManager.add("ALPHA",function(event:ContextMenuEvent):void{ });
			if(copyright) _cmManager.add(copyright,function(event:ContextMenuEvent):void{  },true);
		}
		
		///////////////////////////////////////////////////////////////////////////////
		//								ACCESSORS
		///////////////////////////////////////////////////////////////////////////////
		
		///////////////////////////////
		//-------------------------
		//	manager [read-only]
		//-------------------------
		/**
		 * @private
		 */
		private var _cmManager:CMManager;
		/**
		 * Reference to ContextMenu Manager
		 * 
		 * @return 
		 * 
		 */
		public function get manager():CMManager
		{
			return _cmManager;
		}

	}
}